<template>
	<view>
		<u-navbar title="我的订单" @leftClick="leftClick" :autoback="true"></u-navbar>
		<u-search
			placeholder="专利名称/专利号" 
			v-model="condition.searchName" 
			inputAlign="center"
			:showAction="true" actionText="搜索" :animation="false"
			shape="round"
			borderColor="#bbb"
			@custom="custom"
		></u-search>
		<view class="flex justify-center" v-if="isSearch">
			<u-tabs :list="patentInfos" @click="tabChange" lineWidth="45"  :activeStyle="{
				color: '#5372fc'}"
				:inactiveStyle="{
				color: '#666'}"
				lineColor="#5372fc"
			></u-tabs>
		</view>
		<view class="result" v-else>
			<text>搜索结果：</text>
			<view class="">				
				<text class="result-1">{{total}}</text>
				<text>条</text>
			</view>
		</view>
		<view class="content" v-for="(item,index) in orders" :key="index">
			<ordercomp :infos="item"></ordercomp>
		</view>
		<!--  -->
		<view  class="more" @click="getInitData('more')" v-if="orders.length >= 6">
			加载更多
		</view>
		<u-empty v-if="!orders.length" class="empty-data">
		</u-empty>
	</view>
</template>

<script>
	import {getOrder} from '@/api/index.js'
	import ordercomp from '../../components/orderComp.vue'
	export default {
		components:{ordercomp},
		data() {
			return {
				patentInfos:[
					{name:'全部'},
					{name:'未授权'},
					{name:'已授权'}
				],
				orders:[],
				isSearch:true,
				condition:{
					pageNo:1,
					pageSize:10,
					searchName:'',
					tabId:'0'
				},
				indexSign:1,
				total:0,
			};
		},
		onLoad() {
			this.getInitData();
		},
		methods:{
			getInitData(type){
				if(type) {
					this.indexSign += 1;
				}
				this.condition.pageSize *= this.indexSign;
				getOrder(this.condition).then(res => {
					if(res.code === 200) {
						this.orders = res.data.list;
						this.total = res.data.totalCount;
					}
				})
			},
			leftClick(){
				if (getCurrentPages().length > 1) {
					uni.navigateBack();
				} else {
					uni.switchTab({
						url: '../../pages/index/index'
					})
				}
			},
			jump(){
				uni.navigateTo({
					url:`../order/evaluation`
				})
			},
			custom({value}){
				this.isSearch = false;
				// this.condition.searchName = value;
				this.getInitData();
			},
			tabChange({name,index}){
				this.condition.tabId = index;
				this.getInitData();
			}
		}
	}
</script>

<style lang="scss">
::v-deep .u-tabs__wrapper__nav__item {
	padding: 0 60rpx;
}
.result {
	font-size: 26rpx;
	color: $uni-color-middle;
	margin-top: 46rpx;
	padding: 0 30rpx;
	display: flex;
	justify-content: space-between;
	.result-1 {
		color: #f43738;
		margin: 0 8rpx;
	}
}

.content{
	border-bottom: 16rpx solid #f6f4f8;
}

.image_14 {
  width: 20rpx;
  height: 20rpx;
}
.font_15 {
  font-size: 19rpx;
  font-family: Microsoft YaHei;
  line-height: 18rpx;
  color: #666666;
}
.text_24 {
  margin-left: 12rpx;
}
.text_25 {
  margin-left: 2rpx;
}
.more {
	width: 100%;
	height: 88rpx;
	line-height: 80rpx;
	background: #fff;
	align-items: center;
	text-align: center;
	font-size: 32rpx;
}
</style>
